package com.bloveoacom.util;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.bloveoacom.base.BaseActivity;
import com.bloveoacom.base.BaseFragment;


/**
 * Created by Administrator on 2016/8/26.
 */

public class ActivityUtil {


    public static void startActivity(Context context, Class cls) {
        Intent intent = new Intent(context, cls);
        context.startActivity(intent);
    }


    public static void startActivity(Context context, Class cls, String...data) {
        Bundle bundle = new Bundle();
        for (int i = 0; i < data.length; i++) {
            bundle.putString(getKEY(i),data[i]);
        }
        startActivity(context,cls,bundle);
    }

    public static void startActivity(Context context, Class cls, Bundle bundle) {
        Intent intent = new Intent(context, cls);
        intent.putExtras(bundle);
        context.startActivity(intent);
    }

    public static void startActivityForResult(BaseActivity act, Class cls, int Code) {
        Intent intent = new Intent(act, cls);
        act.startActivityForResult(intent, Code);
    }

    public static void startActivityForResult(BaseActivity act, Class cls, Bundle bundle, int Code) {
        Intent intent = new Intent(act, cls);
        intent.putExtras(bundle);
        act.startActivityForResult(intent, Code);
    }


    public static void startActivityForResult(BaseFragment act, Class cls, int Code) {
        Intent intent = new Intent(act.getActivity(), cls);
        act.startActivityForResult(intent, Code);
    }

    public static void startActivityForResult(BaseFragment act, Class cls, Bundle bundle, int Code) {
        Intent intent = new Intent(act.getActivity(), cls);
        intent.putExtras(bundle);
        act.startActivityForResult(intent, Code);
    }
    public static String getKEY(int i) {
        String key = Constant.DATA;
        switch (i) {
            case 0:
                key = Constant.DATA0;
                break;
            case 1:
                key = Constant.DATA1;
                break;
            case 2:
                key = Constant.DATA2;
                break;
            case 3:
                key = Constant.DATA3;
                break;
            case 4:
                key = Constant.DATA4;
                break;
            case 5:
                key = Constant.DATA5;
                break;
        }
        return key;
    }
}
